export type MapType = {
  setZoomAndCenter: (zoom: number, post: number[]) => void;
}

export type MapRes = {
  AMap: any;
  map: MapType;
  destroy: () => void;
}

export type Location = {
  lat: number;
  lng: number;
}

type PoiPhoto = {
  title: string;
  url: string;
}

export type PoiItem = {
  id: string;
  name: string;
  type: string;
  pname: string;
  cityname: string;
  adname: string;
  address: string;
  adcode: string;
  location: Location;
  photos: PoiPhoto[];
}

export type PoiList = {
  count: number;
  pageIndex: number;
  pageSize: number;
  pois: PoiItem[];
}

export type SearchResult = {
  info: string;
  poiList: PoiList;
}

type SearchCallback = (
  status: string,
  res: SearchResult
) => void;

export type PlaceSearch = {
  setPageIndex: (pageIndex: number) => void;
  search: (keyword: string, callback?: SearchCallback) => void;
}

export type PageType = {
  total: PoiList['count'];
  current: PoiList['pageIndex'];
  pageSize: PoiList['pageSize'];
}

export type SearchPage = [PoiList['pois'], PageType];

type GetAddressHandler = (status: string, result: any) => void;

export type GeocoderRes = {
  getAddress: (
    pos: number[],
    handler: GetAddressHandler
  ) => void;
}